import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Properties;

import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;


public class EmaiSendTest {


	public EmaiSendTest()
	{
		String toAddr = "182100177@qq.com";
		String fromAddr = "182100177@qq.com";
		String host = "smtp.qq.com"; 

		Properties prop = System.getProperties();
		//prop.put("mail.user", "182100177@qq.com");
		//prop.put("mail.password", "zhj7860561");
		prop.put("mail.smtp.host", "smtp.qq.com");
		//prop.put("mail.smtp.auth", "true");

		Session session = Session.getDefaultInstance(prop);

		try
		{
			MimeMessage msg = new MimeMessage(session);
			msg.setFrom(new InternetAddress(fromAddr));
			msg.addRecipient(Message.RecipientType.TO,  new InternetAddress(toAddr));
			msg.setSubject("subject");
			msg.setText("this is the mail body.");
			//session.getTransport().send(msg);
			Transport.send(msg,"182100177","zhj7860561");
			System.out.println("Sent message successfully....");

		}
		catch (MessagingException e)
		{
			System.out.println(e.getMessage());
			e.printStackTrace();
		}







	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new EmaiSendTest();
	}



}
